
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>9、INTERPOLATION · turf源码算法分析</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="lijian">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="chapter10.html" />
    
    
    <link rel="prev" href="chapter8.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    INTRODUCE
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter1.html">
            
                <a href="chapter1.html">
            
                    
                    1、MEASUREMENT
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="chapter2.html">
            
                <a href="chapter2.html">
            
                    
                    2、COORDINATE MUTATION
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="chapter3.html">
            
                <a href="chapter3.html">
            
                    
                    3、TRANSFORMATION
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="chapter4.html">
            
                <a href="chapter4.html">
            
                    
                    4、FEATURE CONVERSION
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="chapter5.html">
            
                <a href="chapter5.html">
            
                    
                    5、MISC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="chapter6.html">
            
                <a href="chapter6.html">
            
                    
                    6、HELPER
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="chapter7.html">
            
                <a href="chapter7.html">
            
                    
                    7、RANDOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="chapter8.html">
            
                <a href="chapter8.html">
            
                    
                    8、DATA
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.10" data-path="chapter9.html">
            
                <a href="chapter9.html">
            
                    
                    9、INTERPOLATION
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="chapter10.html">
            
                <a href="chapter10.html">
            
                    
                    10、JOINS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="chapter11.html">
            
                <a href="chapter11.html">
            
                    
                    11、GRIDS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="chapter12.html">
            
                <a href="chapter12.html">
            
                    
                    12、CLASSIFICATION
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="chapter13.html">
            
                <a href="chapter13.html">
            
                    
                    13、AGGREGATION
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="chapter14.html">
            
                <a href="chapter14.html">
            
                    
                    14、META
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="chapter15.md">
            
                <span>
            
                    
                    15、ASSERTIONS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="chapter16.html">
            
                <a href="chapter16.html">
            
                    
                    16、BOOLEANS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="chapter17.md">
            
                <span>
            
                    
                    17、UNIT CONVERSION
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >9、INTERPOLATION</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="interpolate">interpolate</h1>
<blockquote>
<p>IDW(&#x53CD;&#x8DDD;&#x79BB;&#x6743;&#x91CD;)&#x63D2;&#x503C;</p>
</blockquote>
<p><strong>&#x601D;&#x8DEF;&#xFF1A;</strong> &#x9996;&#x5148;&#x9700;&#x8981;&#x6839;&#x636E;bbox&#x751F;&#x6210;&#x63D2;&#x503C;&#x7684;&#x683C;&#x7F51;&#xFF0C;&#x7136;&#x540E;&#x4F9D;&#x6B21;&#x904D;&#x5386;&#x683C;&#x7F51;&#xFF0C;&#x4F7F;&#x7528;IDW&#x65B9;&#x6CD5;&#x8BA1;&#x7B97;&#x70B9;&#x96C6;&#x5728;&#x8BE5;&#x683C;&#x7F51;&#x7684;&#x63D2;&#x503C;&#x7ED3;&#x679C;&#x3002;</p>
<p><strong>IDW&#x7B97;&#x6CD5;&#xFF1A;</strong></p>
<p>&#x70B9;&#x96C6;V{v1, ... vn},   &#x90A3;&#x4E48;&#x63D2;&#x503C;&#x70B9;P&#x7684;&#x503C;&#x53EF;&#x8868;&#x793A;&#x4E3A;&#xFF1A;</p>
<p><img src="../Image/interpolation1.png" alt=""></p>
<p>di&#x8868;&#x793A;&#x70B9;P&#x4E0E;&#x70B9;vi&#x7684;&#x8DDD;&#x79BB;&#xFF0C;p&#x4EE3;&#x8868;&#x63D2;&#x503C;&#x7CFB;&#x6570;</p>
<p><strong>&#x5B9E;&#x73B0;&#xFF1A;</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> results = [];
featureEach(grid, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">gridFeature</span>) </span>{
    <span class="hljs-keyword">var</span> zw = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">var</span> sw = <span class="hljs-number">0</span>;
    <span class="hljs-comment">// calculate the distance from each input point to the grid points</span>
    featureEach(points, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">point</span>) </span>{
        <span class="hljs-keyword">var</span> gridPoint = (gridType === <span class="hljs-string">&apos;point&apos;</span>) ? gridFeature : centroid(gridFeature);
        <span class="hljs-keyword">var</span> d = distance(gridPoint, point, options);
        <span class="hljs-keyword">var</span> zValue;
        <span class="hljs-comment">// property has priority for zValue, fallbacks to 3rd coordinate from geometry</span>
        <span class="hljs-keyword">if</span> (property !== <span class="hljs-literal">undefined</span>) zValue = point.properties[property];
        <span class="hljs-keyword">if</span> (zValue === <span class="hljs-literal">undefined</span>) zValue = point.geometry.coordinates[<span class="hljs-number">2</span>];
        <span class="hljs-keyword">if</span> (zValue === <span class="hljs-literal">undefined</span>) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&apos;zValue is missing&apos;</span>);
        <span class="hljs-keyword">if</span> (d === <span class="hljs-number">0</span>) zw = zValue;
        <span class="hljs-keyword">var</span> w = <span class="hljs-number">1.0</span> / <span class="hljs-built_in">Math</span>.pow(d, weight);
        sw += w;
        zw += w * zValue;
    });
    <span class="hljs-comment">// write interpolated value for each grid point</span>
    <span class="hljs-keyword">var</span> newFeature = clone(gridFeature);
    newFeature.properties[property] = zw / sw;
    results.push(newFeature);
});
<span class="hljs-keyword">return</span> featureCollection(results);
</code></pre>
<h1 id="isobands&#xFF0C;isolines">isobands&#xFF0C;isolines</h1>
<blockquote>
<p>&#x7B49;&#x503C;&#x9762;&#x548C;&#x7B49;&#x503C;&#x7EBF;&#x7B97;&#x6CD5;&#xFF0C;&#x91C7;&#x7528;&#x7684;&#x662F;&#x5F00;&#x6E90;&#x7684;<a href="https://github.com/RaumZeit/MarchingSquares.js" target="_blank">MarchingSquares&#x7B97;&#x6CD5;</a>&#xFF0C;&#x6CA1;&#x6709;&#x6DF1;&#x7A76;&#xFF0C;&#x80FD;&#x529B;&#x6709;&#x9650;&#x3002;</p>
</blockquote>
<p><img src="../Image/isobands.png" alt=""></p>
<h1 id="planepoint">planepoint</h1>
<blockquote>
<p>&#x83B7;&#x53D6;&#x4E09;&#x89D2;&#x5F62;&#x5185;&#x90E8;&#x67D0;&#x70B9;&#x7684;&#x63D2;&#x503C;&#x7ED3;&#x679C;</p>
</blockquote>
<p><strong>&#x5B9E;&#x73B0;&#x8FC7;&#x7A0B;&#xFF1A;</strong></p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">var</span> x = coord[<span class="hljs-number">0</span>];
  <span class="hljs-keyword">var</span> y = coord[<span class="hljs-number">1</span>];
  <span class="hljs-comment">// &#x4E09;&#x89D2;&#x5F62;&#x7B2C;&#x4E00;&#x4E2A;&#x70B9;&#x7684;xy&#x5750;&#x6807;&#x548C;&#x5C5E;&#x6027;&#x503C;z</span>
  <span class="hljs-keyword">var</span> x1 = outer[<span class="hljs-number">0</span>][<span class="hljs-number">0</span>];
  <span class="hljs-keyword">var</span> y1 = outer[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>];
  <span class="hljs-keyword">var</span> z1 = a !== <span class="hljs-literal">undefined</span> ? a : outer[<span class="hljs-number">0</span>][<span class="hljs-number">2</span>];

  <span class="hljs-comment">// &#x4E09;&#x89D2;&#x5F62;&#x7B2C;&#x4E8C;&#x4E2A;&#x70B9;&#x7684;xy&#x5750;&#x6807;&#x548C;&#x5C5E;&#x6027;&#x503C;z</span>
  <span class="hljs-keyword">var</span> x2 = outer[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>];
  <span class="hljs-keyword">var</span> y2 = outer[<span class="hljs-number">1</span>][<span class="hljs-number">1</span>];
  <span class="hljs-keyword">var</span> z2 = b !== <span class="hljs-literal">undefined</span> ? b : outer[<span class="hljs-number">1</span>][<span class="hljs-number">2</span>];

  <span class="hljs-comment">// &#x4E09;&#x89D2;&#x5F62;&#x7B2C;&#x4E09;&#x4E2A;&#x70B9;&#x7684;xy&#x5750;&#x6807;&#x548C;&#x5C5E;&#x6027;&#x503C;z</span>
  <span class="hljs-keyword">var</span> x3 = outer[<span class="hljs-number">2</span>][<span class="hljs-number">0</span>];
  <span class="hljs-keyword">var</span> y3 = outer[<span class="hljs-number">2</span>][<span class="hljs-number">1</span>];
  <span class="hljs-keyword">var</span> z3 = c !== <span class="hljs-literal">undefined</span> ? c : outer[<span class="hljs-number">2</span>][<span class="hljs-number">2</span>];

  <span class="hljs-comment">// &#x4E09;&#x70B9;&#x5750;&#x6807;IDW&#x63D2;&#x503C;</span>
  <span class="hljs-keyword">var</span> z =
    (z3 * (x - x1) * (y - y2) +
      z1 * (x - x2) * (y - y3) +
      z2 * (x - x3) * (y - y1) -
      z2 * (x - x1) * (y - y3) -
      z3 * (x - x2) * (y - y1) -
      z1 * (x - x3) * (y - y2)) /
    ((x - x1) * (y - y2) +
      (x - x2) * (y - y3) +
      (x - x3) * (y - y1) -
      (x - x1) * (y - y3) -
      (x - x2) * (y - y1) -
      (x - x3) * (y - y2));
</code></pre>
<h1 id="tin">tin</h1>
<blockquote>
<p>&#x4E0D;&#x89C4;&#x5219;&#x4E09;&#x89D2;&#x7F51;&#xFF1A;&#x6A21;&#x578B;&#x91C7;&#x7528;&#x4E00;&#x7CFB;&#x5217;&#x76F8;&#x8FDE;&#x63A5;&#x7684;&#x4E09;&#x89D2;&#x5F62;&#x62DF;&#x5408;&#x5730;&#x8868;&#x6216;&#x5176;&#x4ED6;&#x4E0D;&#x89C4;&#x5219;&#x8868;&#x9762;&#xFF0C;&#x5E38;&#x7528;&#x6765;&#x6784;&#x9020;&#x6570;&#x5B57;&#x5730;&#x9762;&#x6A21;&#x578B;&#xFF0C;&#x7279;&#x522B;&#x662F;&#x6570;&#x5B57;&#x9AD8;&#x7A0B;&#x6A21;&#x578B;&#x3002;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x6A21;&#x62DF;&#x6C14;&#x538B;&#x3001;&#x6C14;&#x6E29;&#x3001;&#x78C1;&#x573A;&#x7B49;&#x5730;&#x7406;&#x73B0;&#x8C61;&#x3002;</p>
</blockquote>
<p>&#x6839;&#x636E;&#x4E00;&#x7EC4;&#x70B9;&#x6570;&#x636E;&#xFF0C;&#x83B7;&#x53D6;&#x4E0D;&#x89C4;&#x5219;&#x4E09;&#x89D2;&#x7F51;&#x7684;&#x591A;&#x8FB9;&#x5F62;&#x6570;&#x636E;</p>
<p><strong>&#x5B9E;&#x73B0;&#x8FC7;&#x7A0B;&#xFF1A;</strong></p>
<p>&#x6211;&#x4EEC;&#x7684;&#x8F93;&#x5165;&#x662F;&#x4E00;&#x7EC4;&#x70B9;&#x6570;&#x636E;&#xFF0C;&#x83B7;&#x53D6;&#x7684;&#x662F;&#x591A;&#x8FB9;&#x5F62;&#x6570;&#x636E;&#xFF0C;&#x800C;&#x591A;&#x8FB9;&#x5F62;&#x6570;&#x636E;&#x4E2D;&#x5305;&#x542B;&#x7684;&#x90FD;&#x662F;&#x4E09;&#x89D2;&#x5F62;&#x3002;&#x6240;&#x4EE5;&#x53EF;&#x4EE5;&#x6709;&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x6B65;&#x9AA4;&#xFF1A;</p>
<p>1&#x3001;&#x5C06;&#x4E00;&#x7EC4;&#x70B9;&#x751F;&#x6210;delaunay&#x4E09;&#x89D2;&#x5F62;</p>
<p>2&#x3001;&#x5C06;&#x751F;&#x6210;&#x7684;&#x4E09;&#x89D2;&#x5F62;&#x7EC4;&#x5408;&#x6210;&#x4E3A;&#x591A;&#x8FB9;&#x5F62;</p>
<p>&#x767E;&#x5EA6;&#x6587;&#x5EAB;&#x6709;&#x76F8;&#x95DC;&#x4ECB;&#x7D39;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x662F;&#x7279;&#x5225;&#x6E05;&#x6670;&#xFF0C;<a href="https://wenku.baidu.com/view/6376d8f29e31433239689309.html" target="_blank">https://wenku.baidu.com/view/6376d8f29e31433239689309.html</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="chapter8.html" class="navigation navigation-prev " aria-label="Previous page: 8、DATA">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="chapter10.html" class="navigation navigation-next " aria-label="Next page: 10、JOINS">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"9、INTERPOLATION","level":"1.10","depth":1,"next":{"title":"10、JOINS","level":"1.11","depth":1,"path":"Chapter/chapter10.md","ref":"Chapter/chapter10.md","articles":[]},"previous":{"title":"8、DATA","level":"1.9","depth":1,"path":"Chapter/chapter8.md","ref":"Chapter/chapter8.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sharing","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["weibo","google","twitter","weibo","instapaper"]},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"lijian","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"turf源码算法分析","language":"zh-hans","gitbook":"3.2.3","description":"turf源码算法分析"},"file":{"path":"Chapter/chapter9.md","mtime":"2021-03-06T01:52:57.096Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-03-28T04:08:06.675Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

